package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.LookLater;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.LookLaterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 邵康
 * @date 2021/12/02 16:31
 */
@Api(tags = "稍后再看")
@CrossOrigin
@RestController
@RequestMapping("/lookLater")
public class LookLaterController {

    @Autowired
    private LookLaterService lookLaterService;

    @ApiOperation("添加收藏 视频id是必须的")
    @PostMapping("/add")
    public R<Void> add(@RequestBody LookLater lookLater) {
        return lookLaterService.add(lookLater);
    }

    @ApiOperation("清除所有已经看过的视频")
    @GetMapping("/removeOver")
    public R<Void> removeOver(){
        return lookLaterService.removeOver();
    }

    @ApiOperation("delete")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return lookLaterService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update(@RequestBody LookLater lookLater) {
        return lookLaterService.update(lookLater);
    }

    @ApiOperation("分页获取稍后再看")
    @GetMapping("/page")
    public R<IPage<LookLater>> page(@RequestParam(defaultValue = "1") Integer page,
                                    @RequestParam(defaultValue = "10") Integer size) {
        return lookLaterService.page(page, size);
    }

}
